public static String validateAssetInfo(AssetInfo assetInfo) {
    List<ArtifactInfo> artifactInfos = assetInfo.getArtifactInfo();
    if (artifactInfos != null) {
      if (validateArtifactInfo(artifactInfos)
          .equalsIgnoreCase(RepositoryServiceClientConstants.FAILURE)) {
        return RepositoryServiceClientConstants.FAILURE;
      }
    }
    if (assetInfo.getAssetLifeCycleInfo() != null) {
      if (validateAssetLifeCycleInfo(assetInfo.getAssetLifeCycleInfo())
          .equalsIgnoreCase(RepositoryServiceClientConstants.FAILURE)) {
        return RepositoryServiceClientConstants.FAILURE;
      }
    }
    if (validateBasicAssetInfo(assetInfo.getBasicAssetInfo())
        .equalsIgnoreCase(RepositoryServiceClientConstants.FAILURE)) {
      return RepositoryServiceClientConstants.FAILURE;
    }
    if (assetInfo.getExtendedAssetInfo() != null) {
      if (validateExtendedAssetInfo(assetInfo.getExtendedAssetInfo())
          .equalsIgnoreCase(RepositoryServiceClientConstants.FAILURE)) {
        return RepositoryServiceClientConstants.FAILURE;
      }
    }
    if (assetInfo.getFlattenedRelationship() != null) {
      if (validateFlattenedRelationship(assetInfo.getFlattenedRelationship())
          .equalsIgnoreCase(RepositoryServiceClientConstants.FAILURE)) {
        return RepositoryServiceClientConstants.FAILURE;
      }
    }

    return RepositoryServiceClientConstants.SUCCESS;
  }
  public void modifySourceRelationship(AssetInfo assetInfo) {

    if (assetInfo.getFlattenedRelationship() != null)
      assetInfo.getFlattenedRelationship().setSourceAsset(null);
  }
  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);
  }