Reply To: migration 1.1.0 -> 2.0.0 simultaneous inbound and outbound rewriting problem

Splash Forums Rewrite Users migration 1.1.0 -> 2.0.0 simultaneous inbound and outbound rewriting problem Reply To: migration 1.1.0 -> 2.0.0 simultaneous inbound and outbound rewriting problem

#23676

kvdev
Participant

this is the relevant code:


//generic inbound url handling
      .addRule()
        .when(Direction.isInbound()
              .and(Path.matches("/{locale}/{path}")))
			.perform(PhaseAction.retrieveFrom(El.retrievalMethod("localeBean.localeCodeChanged"))
					.and(new HttpOperation() {
					@Override
				public void performHttp(HttpServletRewrite event, EvaluationContext context){

                                        HttpInboundServletRewrite inboundEvent = (HttpInboundServletRewrite) event;
							
					//get path and locale
					String path = (String) Evaluation.property("path").retrieve(event, context);
					String locale = (String) Evaluation.property("locale").retrieve(event, context);
							
					String view = getView(locale, "/" + path);	
					Forward.to(view).perform(event, context);
				}
				}))
		.where("locale").matches(SUPPORTED_LOCALES_PATTERN).bindsTo(PhaseBinding.to(El.property("localeBean.localeCode")).after(PhaseId.RESTORE_VIEW))
               	.where("path").matches(".*")

//generic outbound url rewriting
	.addRule()
	.when(Direction.isOutbound()
	       .and(Path.matches("/{viewId}.jsf")
	       .andNot(Path.matches("{*}javax.faces.resource{*}"))
	))
	.perform(new HttpOperation() {
			@Override
			public void performHttp(HttpServletRewrite event, EvaluationContext context){
	
				HttpOutboundServletRewrite outboundEvent = (HttpOutboundServletRewrite) event;
							
				String viewId = (String) Evaluation.property("viewId").retrieve(event, context);
							
				//set locale
				String locale = localeBean.getLocaleCode();
							
				//get path
				String path = getPath(locale, "/" + viewId + ".jsf");
							
				DefaultParameterStore parameterStore = (DefaultParameterStore) context.get(ParameterStore.class);
							
				String targetURL = "/" + locale + path;
							
				Substitute s = Substitute.with(targetURL);
				s.setParameterStore(parameterStore);
				s.perform(event, context);
			}
	}).where("viewId").matches(".*")

When I call the jsf page directly the outbound urls are properly rewritten on the page;
If I call the page through its rewritten inbound url the outbound urls are not rewritten