Skip to content

Commit

Permalink
Merge branch 'master' into Production
Browse files Browse the repository at this point in the history
  • Loading branch information
jezekp committed May 16, 2014
2 parents e45cf39 + a353c34 commit 2160e1e
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ public boolean sendRegistrationConfirmMail(Person user, Locale locale) throws Ma
sb.append(messageSource.getMessage("registration.email.body.clickToRegister", null, locale));
sb.append("<br/>");

String confirmURL = PageParametersUtils.getUrlForPage(ConfirmPage.class, PageParametersUtils.getPageParameters(ConfirmPage.CONFIRM_ACTIVATION, user.getAuthenticationHash()));
String confirmURL = PageParametersUtils.getUrlForPage(ConfirmPage.class,
PageParametersUtils.getPageParameters(ConfirmPage.CONFIRM_ACTIVATION, user.getAuthenticationHash()), domain);
sb.append("<a href=\"" + confirmURL + "\">" + confirmURL + "</a>");
sb.append("</p>");
sb.append("</body></html>");
Expand Down Expand Up @@ -119,7 +120,7 @@ private boolean sendGroupRoleEditMail(String toEmail, int requestId, String user
sb.append("<p>");
sb.append(messageSource.getMessage("editgrouprole.email.body.clickToConfirm", null, locale));
sb.append("<br/>");
String requestUrl = PageParametersUtils.getUrlForPage(GroupRoleAcceptPage.class, PageParametersUtils.getDefaultPageParameters(requestId));
String requestUrl = PageParametersUtils.getUrlForPage(GroupRoleAcceptPage.class, PageParametersUtils.getDefaultPageParameters(requestId), domain);
sb.append("<a href=\"" + requestUrl + "\">" + requestUrl + "</a>");
sb.append("</p>");
sb.append("</body></html>");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@
******************************************************************************/
package cz.zcu.kiv.eegdatabase.logic.eshop;

import cz.zcu.kiv.eegdatabase.wui.app.EEGDataBaseApplication;
import cz.zcu.kiv.eegdatabase.wui.app.session.EEGDataBaseSession;
import cz.zcu.kiv.eegdatabase.wui.components.utils.PageParametersUtils;
import cz.zcu.kiv.eegdatabase.wui.ui.shoppingCart.PayPalConfirmPaymentPage;
import cz.zcu.kiv.eegdatabase.wui.ui.shoppingCart.PaymentErrorPage;
import cz.zcu.kiv.eegdatabase.wui.ui.shoppingCart.ShoppingCartPage;

import org.apache.wicket.protocol.http.WebApplication;

import urn.ebay.api.PayPalAPI.*;
import urn.ebay.apis.CoreComponentTypes.BasicAmountType;
import urn.ebay.apis.eBLBaseComponents.*;
Expand All @@ -49,9 +52,9 @@ public class PayPalTools {
*/
public static String setExpressCheckout(){
// PayPal requires URL to redirect user upon successful payment authorization.
String confirmURL = PageParametersUtils.getUrlForPage(PayPalConfirmPaymentPage.class, null);
String confirmURL = PageParametersUtils.getUrlForPage(PayPalConfirmPaymentPage.class, null, EEGDataBaseApplication.get().getDomain());
// PayPal requires URL to redirect user upon canceling the payment authorization.
String cancelURL = PageParametersUtils.getUrlForPage(ShoppingCartPage.class, null);
String cancelURL = PageParametersUtils.getUrlForPage(ShoppingCartPage.class, null, EEGDataBaseApplication.get().getDomain());

try{
// PayPal SDK requires property object as a constructor parameter.
Expand Down Expand Up @@ -100,7 +103,7 @@ public static String setExpressCheckout(){
return (PayPalProperties.getProperty("service.SetExpressCheckoutRedirectURL") + token);
}
} catch (Exception e) {}
return PageParametersUtils.getUrlForPage(PaymentErrorPage.class, null);
return PageParametersUtils.getUrlForPage(PaymentErrorPage.class, null, EEGDataBaseApplication.get().getDomain());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,21 @@
import org.apache.wicket.ConverterLocator;
import org.apache.wicket.IConverterLocator;
import org.apache.wicket.Page;
import org.apache.wicket.RuntimeConfigurationType;
import org.apache.wicket.Session;
import org.apache.wicket.authroles.authentication.AbstractAuthenticatedWebSession;
import org.apache.wicket.authroles.authentication.AuthenticatedWebApplication;
import org.apache.wicket.authroles.authorization.strategies.role.annotations.AnnotationsRoleAuthorizationStrategy;
import org.apache.wicket.core.request.mapper.CryptoMapper;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.request.Request;
import org.apache.wicket.request.Response;
import org.apache.wicket.settings.IExceptionSettings;
import org.apache.wicket.spring.injection.annot.SpringComponentInjector;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

Expand Down Expand Up @@ -134,6 +137,9 @@
public class EEGDataBaseApplication extends AuthenticatedWebApplication implements ApplicationContextAware {

private ApplicationContext appCtx;

@Value("${app.domain}")
private String domain;

@Autowired
private DiseaseFacade diseaseFacade;
Expand Down Expand Up @@ -163,12 +169,17 @@ public java.lang.Class<? extends Page> getHomePage() {

return HomePage.class;
};

public static EEGDataBaseApplication get()
{
return (EEGDataBaseApplication) AuthenticatedWebApplication.get();
}

@Override
public void init() {
super.init();
getDebugSettings().setOutputComponentPath(true);

getDebugSettings().setOutputComponentPath(development);
getMarkupSettings().setStripWicketTags(true);
// getMarkupSettings().setCompressWhitespace(true);
getMarkupSettings().setStripComments(true);
Expand All @@ -180,9 +191,11 @@ public void init() {
// set access denied page inserted in menu content.
getApplicationSettings().setAccessDeniedPage(AccessDeniedPage.class);
getApplicationSettings().setInternalErrorPage(InternalErrorPage.class);
if(!development)
getExceptionSettings().setUnexpectedExceptionDisplay(IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE);

if(!development){

getExceptionSettings().setUnexpectedExceptionDisplay(IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE);
}
// set true for upload progress.
getApplicationSettings().setUploadProgressUpdatesEnabled(true);

Expand All @@ -198,6 +211,12 @@ public void init() {

}

@Override
public RuntimeConfigurationType getConfigurationType() {

return development ? RuntimeConfigurationType.DEVELOPMENT : RuntimeConfigurationType.DEPLOYMENT;
}

/**
* Mount pages on specific URL.
*/
Expand Down Expand Up @@ -316,5 +335,9 @@ protected Class<? extends WebPage> getSignInPageClass() {
public void setDevelopment(boolean development) {
this.development = development;
}

public String getDomain() {
return domain;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,14 @@ public static PageParameters addParameters(PageParameters parameters,
* @param parameters
* @return
*/
public static String getUrlForPage(Class page, PageParameters parameters) {

return RequestCycle.get().getUrlRenderer().renderFullUrl(
Url.parse(RequestCycle.get().urlFor(page, parameters).toString()));
public static String getUrlForPage(Class page, PageParameters parameters, String appDomain) {

String url = appDomain;
boolean endWithSlash = url.endsWith("/");

if(!endWithSlash)
url = url + "/";

return url + RequestCycle.get().urlFor(page, parameters).toString().substring(2);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ <h2>
-->

</div>
<!-- XXX #66 Java Heap Space Exception : working with big data file in memory.
<div wicket:id="container">
<!-- XXX #66 Java Heap Space Exception : working with big data file in memory.
<div wicket:id="view"></div>
</div>
-->
</div>
</div>
</wicket:extend>
</body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,9 @@ protected Iterator<Scenario> getChoices(String input) {
choices = new ArrayList<Scenario>(10);
for (Scenario t : allChoices) {
if ((t.getTitle() != null) &&
t.getTitle().toLowerCase().startsWith(input.toLowerCase())) {
t.getTitle().toLowerCase().contains(input.toLowerCase())) {
choices.add(t);
}
if (choices.size() >= 10) {
break;
}
}
}
Collections.sort(choices);
Expand Down Expand Up @@ -349,12 +346,9 @@ protected Iterator<Person> getChoices(String input) {
choices = new ArrayList<Person>(10);
for (Person t : allChoices) {
if ((t.getFullName() != null) &&
t.getFullName().toLowerCase().startsWith(input.toLowerCase())) {
t.getFullName().toLowerCase().contains(input.toLowerCase())) {
choices.add(t);
}
if (choices.size() >= 10) {
break;
}
}
}
Collections.sort(choices);
Expand Down Expand Up @@ -410,11 +404,11 @@ private void createModalWindows() {
private AutoCompleteSettings prepareAutoCompleteSettings() {

AutoCompleteSettings settings = new AutoCompleteSettings();
settings.setShowCompleteListOnFocusGain(true);
settings.setShowListOnEmptyInput(true);
settings.setPreselect(true);
settings.setShowListOnFocusGain(true);
settings.setShowCompleteListOnFocusGain(true);
settings.setUseHideShowCoveredIEFix(false);
settings.setMaxHeightInPx(200);
settings.setAdjustInputWidth(false);
return settings;
}

Expand Down
12 changes: 6 additions & 6 deletions src/main/webapp/WEB-INF/facebook.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
# facebook.properties, 2013/10/02 00:01 Jakub Rinkes
#-------------------------------------------------------------------------------
# *************** 1. LOCALHOST ********************
facebook.appId = 134626213275344
facebook.appSecret = a0e3aecb5b427c79d79bb9ac52542035
redirect.uri = http://localhost:8080/home-page
#facebook.appId = 134626213275344
#facebook.appSecret = a0e3aecb5b427c79d79bb9ac52542035
#redirect.uri = http://localhost:8080/home-page

# *************** 2. TESTING SERVER ***************
#facebook.appId = 218187598193669
#facebook.appSecret = deef998440795611cb8f2ee635e47a0b
#redirect.uri = http://147.228.64.172:8080/home-page
facebook.appId = 218187598193669
facebook.appSecret = deef998440795611cb8f2ee635e47a0b
redirect.uri = http://147.228.64.172:8080/home-page


# *************** 3. RELEASE SERVER ***************
Expand Down
8 changes: 4 additions & 4 deletions src/main/webapp/WEB-INF/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ development=true

# This url is the url which returns callback after authorization of users on social sites.
# This url is same like app.domain if there isnt any problem with callback and proxies.
# If callback have to come back to app via another url or port change it.
app.appUrlForSocialSites=http://147.228.64.172:8080

app.domain=http://147.228.64.172:8080
# If callback have to come back to app via another url or port change it. End it with slash.
app.appUrlForSocialSites=http://147.228.64.172:8080/
# end url with slash for right generating url from app domain for email, etc.
app.domain=http://147.228.64.172:8080/
email.smtp=smtp.zcu.cz
email.from=[email protected]
email.subject=EEG/ERP portal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,54 @@ public void testCreateExperiment() {
assertNotNull(experimentDao.read(experiment.getExperimentId()));
assertEquals(1, experimentDao.getCountRecords());

}

@Test
@Transactional
public void testGetCountExperimentsWhereOwner() {
int count = experimentDao.getCountForExperimentsWhereOwner(person);
experimentDao.create(experiment);
Person person1 = TestUtils.createPersonForTesting("[email protected]", Util.ROLE_READER);
personDao.create(person1);
Experiment exp = setUpExperiment();
exp.setPersonByOwnerId(person1);
experimentDao.create(exp);
assertEquals(count + 1, experimentDao.getCountForExperimentsWhereOwner(person));

}

@Test
@Transactional
public void testGetCountExperimentsWhereSubject() {
int countForOwner = experimentDao.getCountForExperimentsWhereOwner(person);
int countForSubject = experimentDao.getCountForExperimentsWhereSubject(person);
experimentDao.create(experiment);
Person person1 = TestUtils.createPersonForTesting("[email protected]", Util.ROLE_READER);
personDao.create(person1);
Experiment exp = setUpExperiment();
exp.setPersonBySubjectPersonId(person1);
experimentDao.create(exp);
assertEquals(countForOwner + 2, experimentDao.getCountForExperimentsWhereOwner(person));
assertEquals(countForSubject + 1, experimentDao.getCountForExperimentsWhereSubject(person));

}

@Test
@Transactional
public void testGetExperimentForDetail() {

experimentDao.create(experiment);
Experiment exp = experimentDao.getExperimentForDetail(experiment.getExperimentId());
assertEquals("testTitle", exp.getResearchGroup().getTitle());
assertEquals("[email protected]", exp.getPersonBySubjectPersonId().getUsername());
assertEquals("testTitleWeather", exp.getWeather().getTitle());
for (Software sw: exp.getSoftwares()) {
assertEquals("testTitleSW", sw.getTitle());
}




}

@After
Expand Down Expand Up @@ -151,14 +199,14 @@ private Hardware createHardware() {
private Software createSoftware() {
Software software = new Software();
software.setDescription("testDesc");
software.setTitle("testTitle");
software.setTitle("testTitleSW");
softwareDao.create(software);
return software;
}

private Weather createWeather() {
Weather weather = new Weather();
weather.setTitle("testTitle");
weather.setTitle("testTitleWeather");
weather.setDescription("testDesc");
weatherDao.create(weather);
return weather;
Expand Down

0 comments on commit 2160e1e

Please sign in to comment.