/*
 * Licensed to Jasig under one or more contributor license
 * agreements. See the NOTICE file distributed with this work
 * for additional information regarding copyright ownership.
 * Jasig licenses this file to you under the Apache License,
 * Version 2.0 (the "License"); you may not use this file
 * except in compliance with the License.  You may obtain a
 * copy of the License at the following location:
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package io.cos.cas.web.flow;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.webflow.execution.Event;
import org.springframework.webflow.execution.RequestContext;

import java.net.MalformedURLException;
import java.net.URL;

/**
 * Open Science Framework Login View.
 *
 * @author Longze Chen
 * @since 4.1.0
 */
public class OpenScienceFrameworkLoginViews {

    private static final Logger LOGGER = LoggerFactory.getLogger(OpenScienceFrameworkLoginViews.class);

    /** Default Constructor. */
    public OpenScienceFrameworkLoginViews() {}

    /**
     * Check the campaign in service url.
     * @param context The request context
     * @return Event
     */
    public Event checkOsfCampaigns(final RequestContext context) {
        final String service = context.getRequestParameters().get("service");
        String serviceCampaign = null;
        URL serviceUrl = null;
        try {
            serviceUrl = new URL(service);
        } catch (final MalformedURLException e) {
            LOGGER.error(String.format("Malformed Service URL: %s", e.toString()));
        }
        if (serviceUrl != null) {
            final String servicePath = serviceUrl.getPath();
            if (servicePath.startsWith("/prereg/")) {
                serviceCampaign = "PREREG";
            } else if (servicePath.startsWith("/erpc/")) {
                serviceCampaign = "ERPC";
            } else if (servicePath.startsWith("/preprints")) {
                serviceCampaign = "PREPRINTS";
            }
        }
        if (serviceCampaign != null) {
            context.getFlowScope().put("serviceCampaign", serviceCampaign);
        }
        return new Event(this, "success");
    }
}

@@ -1557,24 +1557,25 @@
  context) %7B%0A
+%0A
         fina
@@ -1702,32 +1702,33 @@
 viceUrl = null;%0A
+%0A
         try %7B%0A  
@@ -1904,32 +1904,33 @@
 ()));%0A        %7D%0A
+%0A
         if (serv
@@ -2305,16 +2305,20 @@
 aign = %22
+OSF-
 PREPRINT
@@ -2337,32 +2337,33 @@
     %7D%0A        %7D%0A
+%0A
         if (serv
@@ -2461,16 +2461,192 @@
 paign);%0A
+            context.getFlowScope().put(%0A                    %22registerCampaign%22,%0A                    String.format(%22?campaign=%25s%22, serviceCampaign.toLowerCase())%0A            );%0A
         
@@ -2639,32 +2639,33 @@
    );%0A        %7D%0A
+%0A
         return n

Put campaign for "Create Account" osf redirection.