All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.symphony.oss.models.fundmental.canon.SequencesSequenceHashPagePathHandler Maven / Gradle / Ivy

/**
 * GENERATED CODE - DO NOT EDIT OR CHECK IN TO SOURCE CODE CONTROL
 *
 * Copyright 2020 Symphony Communication Services, LLC.
 *
 * Licensed 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
 *
 *     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.
 *
 *----------------------------------------------------------------------------------------------------
 * Generated from
 *    Input source         file:/Users/bruce/symphony/git-SymphonyOSF/oss-models/target/checkout/fundamental-model/src/main/resources/canon/fundamental.json
 *    Template groupId     org.symphonyoss.s2.canon
 *           artifactId    canon-template-java
 *    Template name        template/java/Path/_PathHandler.java.ftl
 *    At                   2020-01-28 16:55:36 GMT
 *----------------------------------------------------------------------------------------------------
 */

package com.symphony.oss.models.fundmental.canon;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

import java.io.IOException;

import java.util.Iterator;
import java.util.List;

import org.symphonyoss.s2.canon.runtime.PathHandler;
import org.symphonyoss.s2.canon.runtime.ModelRegistry;
import org.symphonyoss.s2.canon.runtime.exception.BadRequestException;
import org.symphonyoss.s2.canon.runtime.exception.CanonException;
import org.symphonyoss.s2.canon.runtime.exception.NotFoundException;
import org.symphonyoss.s2.canon.runtime.exception.PermissionDeniedException;
import org.symphonyoss.s2.canon.runtime.exception.ServerErrorException;
import org.symphonyoss.s2.canon.runtime.http.IRequestAuthenticator;
import org.symphonyoss.s2.canon.runtime.http.ParameterLocation;
import org.symphonyoss.s2.canon.runtime.http.IRequestContext;

import java.util.List;
import java.util.LinkedList;
import com.google.common.collect.ImmutableList;
import org.symphonyoss.s2.common.immutable.ImmutableByteArray;
import org.symphonyoss.s2.common.hash.Hash;
import com.symphony.oss.models.fundamental.canon.facade.*;
import com.symphony.oss.models.crypto.canon.facade.*;
import com.symphony.oss.models.crypto.canon.*;
import com.symphony.oss.models.core.canon.facade.*;
import com.symphony.oss.models.core.canon.*;

/**
 * Path name=SequencesSequenceHashPage
 *
 * Path					/sequences/{sequenceHash}/page
 * Bind Path			sequences/
 */
@Immutable
@SuppressWarnings("unused")
public abstract class SequencesSequenceHashPagePathHandler extends PathHandler implements ISequencesSequenceHashPagePathHandler
{
  private final String path_;
  
  public SequencesSequenceHashPagePathHandler(@Nullable IRequestAuthenticator authenticator)
  {
    this(authenticator, "");
  }
  
  public SequencesSequenceHashPagePathHandler(@Nullable IRequestAuthenticator authenticator, String basePath)
  {
    super(authenticator, 1, new String[] {
        basePath + "/object/fundamental/v1/sequences/",
        "/page"
      }
    );
    
    path_ = basePath + "/object/fundamental/v1/sequences/{sequenceHash}/page";
  }

  @Override
  public String getPath()
  {
    return path_;
  }

  @Override
  public void handle(T auth, IRequestContext context, List pathParams) throws IOException, CanonException
  {
    switch(context.getMethod())
    {
      case Post:
      case Put:
      case Delete:
      case Options:
      case Head:
      case Trace:
        unsupportedMethod(auth, context);
        break;
        
      case Get:
        doGet(auth, context, pathParams);
        break;
        
    }
  }

  private void doGet(T auth, IRequestContext context, List pathParams) throws IOException, CanonException
  {
    Iterator it = pathParams.iterator();
  
    // We have already checked that there are the correct number of parameters
      
    ImmutableByteArray        sequenceHashValue = context.asImmutableByteArray("sequenceHash", it.next());
    Hash                      sequenceHash = null;

    try
    {
      sequenceHash = Hash.build(sequenceHashValue);
    }
    catch(NullPointerException | IllegalArgumentException e)
    {
      context.error("Parameter \"sequenceHash\" has invalid value \"%s\" (%s)", sequenceHashValue, e.getMessage());
    }
    
    
  

    Integer                   limitValue = context.getParameterAsInteger("limit", ParameterLocation.Query, false);
    Integer                   limit = null; 
    
    if(limitValue != null)
    {
      limit = limitValue;
    }


    Boolean                   scanForwardsValue = context.getParameterAsBoolean("scanForwards", ParameterLocation.Query, false);
    Boolean                   scanForwards = null; 
    
    if(scanForwardsValue != null)
    {
      scanForwards = scanForwardsValue;
    }


    String                    afterValue = context.getParameterAsString("after", ParameterLocation.Query, false);
    String                    after = null; 
    
    if(afterValue != null)
    {
      after = afterValue;
    }

  
    if(context.preConditionsAreMet())
    {
      try
      {
        IPageOfFundamentalObject response =
          handleGet(
            auth,
            context.getTrace(),
            sequenceHash,
            limit,
            scanForwards,
            after  
          );
        if(response == null)
        {
          throw new NotFoundException();      
        }
        else
        {
          context.sendOKResponse(response);
        }
      }
      catch(CanonException e)
      {
        throw e;
      }
      catch(RuntimeException e)
      {
        throw new ServerErrorException(e);
      }
    }
  }


}
/*----------------------------------------------------------------------------------------------------
 * End of template template/java/Path/_PathHandler.java.ftl
 * End of code generation
 *------------------------------------------------------------------------------------------------- */




© 2015 - 2025 Weber Informatics LLC | Privacy Policy