View Javadoc
1   /*
2    * Copyright 2013 the original author or authors.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *     
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.openehealth.ipf.commons.ihe.xds.core.validate.requests;
17  
18  import org.openehealth.ipf.commons.core.modules.api.Validator;
19  import org.openehealth.ipf.commons.ihe.xds.core.ebxml.EbXMLRemoveMetadataRequest;
20  import org.openehealth.ipf.commons.ihe.xds.core.validate.ValidationProfile;
21  
22  import static org.openehealth.ipf.commons.ihe.xds.XDS.Interactions.ITI_62;
23  import static org.openehealth.ipf.commons.ihe.xds.core.validate.ValidationMessage.EMPTY_REFERENCE_LIST;
24  import static org.openehealth.ipf.commons.ihe.xds.core.validate.ValidationMessage.OBJECT_SHALL_NOT_BE_SPECIFIED;
25  import static org.openehealth.ipf.commons.ihe.xds.core.validate.ValidatorAssertions.metaDataAssert;
26  
27  /**
28   * Validates a {@link EbXMLRemoveMetadataRequest} request.
29   * @author Boris Stanojevic
30   */
31  public class RemoveMetadataRequestValidator implements Validator<EbXMLRemoveMetadataRequest, ValidationProfile> {
32  
33      /**
34       * Validates the request.
35       * @param request
36       *          the request.
37       * @throws org.openehealth.ipf.commons.ihe.xds.core.validate.XDSMetaDataException
38       *          if the validation failed.
39       */
40      @Override
41      public void validate(EbXMLRemoveMetadataRequest request, ValidationProfile profile)  {
42          if (profile == ITI_62) {
43              metaDataAssert(request.getReferences().size() > 0, EMPTY_REFERENCE_LIST, "RemoveObjectsRequest");
44              metaDataAssert(request.getId() == null &&
45                             request.getHome() == null &&
46                             request.getSql() == null &&
47                             request.getSlots().isEmpty(), OBJECT_SHALL_NOT_BE_SPECIFIED, "AdhocQuery");
48          }
49      }
50  }