Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /* 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.
  */
 package com.labs64.utils.swid.processor;
 
 
Default SWID tag processor creates SWID tag with pre-defined mandatory elements.

See also:
ISO/IEC 19770-2:2009 for guidance.
 
 public class DefaultSwidProcessor implements SwidProcessor {
 
     protected final SoftwareIdentificationTagComplexType swidTag;
 
     protected IdGenerator idGenerator;

    
Creates SWID Tag default processor.
 
     public DefaultSwidProcessor() {
          = new SoftwareIdentificationTagComplexType();
         setGenerator(new NullIdGenerator());
     }

    
Set element identifier generator.

Parameters:
generator element identifier generator
 
     public void setGenerator(final IdGenerator generator) {
         if (generator != null) {
             this. = generator;
             .setId(.nextId());
         }
     }

    

Identifies whether this product needs to match up with an entitlement for a reconciliation to be considered successful (tag: entitlement_required_indicator).

Specifies if an entitlement is required to reconcile this product. Example data format: XX = entitlement status ( true = entitlement required; false = no entitlement required).

Parameters:
entitlementRequiredIndicator entitlements required indicator
Returns:
a reference to this object.
 
     public DefaultSwidProcessor setEntitlementRequiredIndicator(final boolean entitlementRequiredIndicator) {
                 new org.iso.standards.iso._19770.__2._2009.schema.Boolean(entitlementRequiredIndicator
                         .nextId()));
         return this;
     }

    

Accurately identifies the product (tag: product_title).

Parameters:
productTitle product title
Returns:
a reference to this object.
 
     public DefaultSwidProcessor setProductTitle(final String productTitle) {
         .setProductTitle(
                 new Token(productTitle.nextId()));
         return this;
     }

    
Identifies the product version (tag: product_version) using two values – numeric version and version string.

Parameters:
productVersion product version
productVersionMajor product major version
productVersionMinor product minor version
productVersionBuild product build version
productVersionReview product review version
Returns:
a reference to this object.
    public DefaultSwidProcessor setProductVersion(final String productVersion,
            final long productVersionMajor,
            final long productVersionMinor,
            final long productVersionBuild,
            final long productVersionReview) {
        final NumericVersionComplexType numericVersion = new NumericVersionComplexType(
                new UInt(productVersionMajor.nextId()),
                new UInt(productVersionMinor.nextId()),
                new UInt(productVersionBuild.nextId()),
                new UInt(productVersionReview.nextId()),
                .nextId());
        .setProductVersion(
                new ProductVersionComplexType(
                        new Token(productVersion.nextId()), numericVersion.nextId()));
        return this;
    }

    
Identifies the creator of the software (tag: software_creator).

Parameters:
softwareCreatorName software creator name
softwareCreatorRegId software creator registration ID
Returns:
a reference to this object.
    public DefaultSwidProcessor setSoftwareCreator(final String softwareCreatorNamefinal String softwareCreatorRegId) {
                new EntityComplexType(
                        new Token(softwareCreatorName.nextId()),
                        new RegistrationId(softwareCreatorRegId.nextId()),
                        .nextId()));
        return this;
    }

    
Identifies the licensor of the software (tag: software_licensor).

Parameters:
softwareLicensorName software licensor name
softwareLicensorRegId software licensor registration ID
Returns:
a reference to this object.
    public DefaultSwidProcessor setSoftwareLicensor(final String softwareLicensorName,
            final String softwareLicensorRegId) {
                new EntityComplexType(
                        new Token(softwareLicensorName.nextId()),
                        new RegistrationId(softwareLicensorRegId.nextId()),
                        .nextId()));
        return this;
    }

    
Identifies the specific version of a product (tag: software_id).

Parameters:
uniqueId software unique ID
tagCreatorRegid tag creator registration ID
Returns:
a reference to this object.
    public DefaultSwidProcessor setSoftwareId(final String uniqueIdfinal String tagCreatorRegid) {
        .setSoftwareId(
                new SoftwareIdComplexType(
                        new Token(uniqueId.nextId()),
                        new RegistrationId(tagCreatorRegid.nextId()),
                        .nextId()));
        return this;
    }

    

Identifies the tag creator (tag: tag_creator).

Example data format: “regid.2010-04.com.labs64,NLIC” where:

  • regid = registered id
  • 2010-04 = the year and first month the domain was registered (yyyy-mm)
  • com = the upper level domain
  • labs64 = the domain name
  • NLIC = the name of the business unit (BU) that created the SWID tag

Note that everything after the comma ‘,’ is optional and only required if a software title is specific

Parameters:
tagCreatorName tag creator name
tagCreatorRegId tag creator registration ID
Returns:
a reference to this object.
    public DefaultSwidProcessor setTagCreator(final String tagCreatorNamefinal String tagCreatorRegId) {
        .setTagCreator(
                new EntityComplexType(
                        new Token(tagCreatorName.nextId()),
                        new RegistrationId(tagCreatorRegId.nextId()),
                        .nextId()));
        return this;
    }

    
Validate whether processor configuration is valid.

Throws:
com.labs64.utils.swid.exception.SwidException in case of invalid processor configuration
    public void validate() {
        if (.getEntitlementRequiredIndicator() == null) {
            throw new SwidException("'entitlement_required_indicator' is not set");
        }
        if (.getProductTitle() == null) {
            throw new SwidException("'product_title' is not set");
        }
        if (.getProductVersion() == null) {
            throw new SwidException("'product_version' is not set");
        }
        if (.getSoftwareCreator() == null) {
            throw new SwidException("'software_creator' is not set");
        }
        if (.getSoftwareLicensor() == null) {
            throw new SwidException("'software_licensor' is not set");
        }
        if (.getSoftwareId() == null) {
            throw new SwidException("'software_id' is not set");
        }
        if (.getTagCreator() == null) {
            throw new SwidException("'tag_creator' is not set");
        }
    }
    @Override
        validate();
        return ;
    }
New to GrepCode? Check out our FAQ X