public static String validateFlattenedRelationship(FlattenedRelationship flattenedRelationship) {
    if (validateAssetKey(flattenedRelationship.getSourceAsset())
        .equalsIgnoreCase(RepositoryServiceClientConstants.FAILURE)) {
      return RepositoryServiceClientConstants.FAILURE;
    }
    List<Relation> relations = flattenedRelationship.getRelatedAsset();
    if (relations != null) {
      if (validateRelations(relations).equalsIgnoreCase(RepositoryServiceClientConstants.FAILURE)) {
        return RepositoryServiceClientConstants.FAILURE;
      }
    }

    return RepositoryServiceClientConstants.SUCCESS;
  }
  private CreateCompleteAssetResponse createAsset() throws Exception {
    AssetKey key = new AssetKey();
    Library lib = new Library();
    lib.setLibraryName(libraryName);
    key.setLibrary(lib);
    key.setAssetName(assetName);

    BasicAssetInfo basicInfo = new BasicAssetInfo();
    basicInfo.setAssetKey(key);
    basicInfo.setAssetName(assetName);
    basicInfo.setAssetDescription(assetDesc);
    basicInfo.setAssetType("Service");

    ExtendedAssetInfo extendedInfo = new ExtendedAssetInfo();
    List<AttributeNameValue> attrs = extendedInfo.getAttribute();
    attrs.add(RSProviderUtil.newAttribute("namespace", libraryName));

    AssetLifeCycleInfo lifeCycleInfo = new AssetLifeCycleInfo();
    lifeCycleInfo.setDomainOwner("John Doe");
    lifeCycleInfo.setDomainType("Technical Owner");

    AssetInfo assetInfo = new AssetInfo();
    assetInfo.setBasicAssetInfo(basicInfo);
    assetInfo.setExtendedAssetInfo(extendedInfo);
    assetInfo.setAssetLifeCycleInfo(lifeCycleInfo);

    Artifact endpoint = new Artifact();
    endpoint.setArtifactName("ep-" + assetName);
    endpoint.setArtifactCategory("Endpoint");
    endpoint.setArtifactValueType(ArtifactValueType.URL);

    String endpointUrl = baseUrl + assetName;
    ArtifactInfo endpointInfo = new ArtifactInfo();
    endpointInfo.setArtifact(endpoint);
    endpointInfo.setArtifactDetail(endpointUrl.getBytes("UTF-8"));
    endpointInfo.setContentType("application/vnd.wso2.endpoint");

    List<ArtifactInfo> artifactList = assetInfo.getArtifactInfo();
    artifactList.add(endpointInfo);

    FlattenedRelationship relationship = new FlattenedRelationship();
    List<Relation> relationList = relationship.getRelatedAsset();
    relationList.add(
        new Relation() {
          {
            this.setSourceAsset(
                RSProviderUtil.completeAssetKey(
                    new AssetKey() {
                      {
                        this.setAssetId(resources[0]);
                      }
                    },
                    null,
                    null));
            this.setTargetAsset(
                RSProviderUtil.completeAssetKey(
                    new AssetKey() {
                      {
                        this.setAssetId(dstAssets[0]);
                      }
                    },
                    null,
                    null));
            this.setAssetRelationship("DependsOn");
          }
        });
    assetInfo.setFlattenedRelationship(relationship);

    CreateCompleteAssetRequest request = new CreateCompleteAssetRequest();
    request.setAssetInfo(assetInfo);

    RepositoryServiceProviderImpl provider = new RepositoryServiceProviderImpl();
    return provider.createCompleteAsset(request);
  }