Managing Assets

These are methods for importing data files into Storefront or updating or removing them.

DeleteAsset

Since version 2.5

Marks an asset deleted.

Method

int DeleteAsset(string assetID)

Parameters

assetID — Asset identifier.

Returns

Normally, eSuccess. Returns an eBadObjectID error if assetID does not correspond to an asset.

ExportProduct

Since version 9.8

Export a product file (.SFP) to a specified location.

Method

bool ExportProduct(string outputPath,

               string productId,

               bool exportProjectFiles,

               bool exportGlobalFiles,

               out List<SINIMessage> messages);

Parameters

outputPath —Location of the file to write .

productId —ID of the product to export. This can refer to either a staged or a live product .

exportProjectFiles — Whether or not to export the project files with the product.

exportGlobalFiles — Whether or not to export the global files with the product.

messages — A list of messages arising from the export process (see “SINIMessage,” below).

Returns

True or false depending on whether the export succeeded.

SINIMessage

The SINIMessage structure allows information to be conveyed back to the caller.

public class SINIMessage

{

public int Level { get; set; }

public string Message { get; set; }

public int Code { get; set; }

public string Extra { get; set; }

}

 

Level — Values in this field may be 0 (= information), 1 (= warning), or 2 (= error or exception).

Message — Message for display to a user, from the following:

Code

Message

0

Generic message (usually an exception)

100

Blank line

5001

Exception while exporting product

5002

Data error: column count different from row data

5003

Data error: more than one id={XXX} in {table}

5004

Exception while copying {filename}

5005

Trying to mark flags {XX} with mark {Y}

5100

Product could not be imported

5101

Imported new project ‘{NAME}’

5102

Exception while installing fonts

5103

Product code {CODE} was in use and will be cleared.

5104

Product Social Media Permalink {PERM} was in use and will be cleared.

5105

There are no product categories in the deployment.

5106

Imported new product ‘{NAME}’ (or: Imported new version of product ‘{NAME}’)

5107

Some project fonts could not be installed, so the product might not work properly.

5108

Unable to delete imported files in ‘{FOLDER}’

5109

The following Asset/Product Metadata field objects are not present in the deployment but have imported values: {NAMES}

5110

Imported file is from a future Storefront version ({VERSION}) and may not import correctly.

5111

Custom file {FILE} is missing from the deployment and will not be copied

5112

File {FILE} is missing from the deployment and will not be copied

5113

Replacing file: {FILE}

5114

Assigning product to categories ‘{CATEGORIES}’

5115

No file for manually generated product thumbnail: auto-generating

5116

Regenerating product thumbnail

5117

Internal error: placeholder row without an id: {row}

5118

Using price table ‘{NAME}’ which was already in the deployment.

5119

Unresolved placeholders

5120

String {S} was not re-mapped

Code — Integer uniquely identifying the message (or message template), from the table above.

Extra — Specific information from the message, such as a filename or product code.

Remarks

If any of the returned messages has a status of Error (2), then the export failed and the return value should be false.

GetDocumentExtensionErrors

Since version 3.0

Gets an array of (key, value) pairs, one for each SXI module that has set a non-null error message for the given document.

Method

KeyValuePair[] GetDocumentExtensionErrors(string documentId)

Parameters

documentId — Internal identifier of the document.

Returns

Returns null if documentId is not a valid document ID. Otherwise returns all extension-managed errors.

ImportDatabase

Since version 2.5

Copy a database asset into Storefront.

Method

string ImportDatabase(string filename, string ownerID)

Parameters

filename — Full path to the file to be imported as a new asset. As with user-uploaded databases, a copy is made of the file within Storefront’s asset directory and the original file is not used after the import.

ownerID — Internal owner identifier of the new asset, or null for a global database.

Returns

This method returns the asset ID of the database CSV file.

ImportImage

Since version 2.5

Copy an image asset into Storefront.

Method

string ImportImage(string filename, string ownerID)

Parameters

filename — Full path to the file to be imported as a new asset. As with user-uploaded images, a copy is made of the file within Storefront’s asset directory and the original file is not used after the import.

ownerID — Internal owner identifier of the new asset, or null for a global library image.

Returns

This method returns the asset ID of the image.

ImportPdfDocument

Since version 3.0

Copy a PDF as a document asset into Storefront.

Method

string ImportPdfDocument(string filename, string ownerID)

Parameters

filename — Full path to the file to be imported as a new asset. As with user-uploaded PDF documents, a copy is made of the file within Storefront’s asset directory and the original file is not used after the import.

ownerID — Internal owner identifier of the new asset, or null for a global library image.

Returns

This method returns the asset ID of the document.

ImportProduct

Since version 9.8

Import a product file (.SFP) to the deployment as a staged product.

Method

bool ImportProduct(string inputPath,

               ImporterConfiguration config,

               out List<SINIMessage> messages);

Parameters

inputPath —Location of the file to import .

config —Structure with configuration parameters for the import process (see “ImporterConfiguration,” below) .

messages — A list of messages arising from the import process (see “SINIMessage,” below).

Returns

The product ID of the newly-imported product.

ImporterConfiguration

public class ImporterConfiguration

{

   string productIdToReplace {get; set; }

   string projectIdToUse {get; set; }

   string categoryId {get; set; }

   bool importProjectAssets {get; set; }

   bool overwriteExistingProjectAssets {get; set; }

   bool importGlobalAssets {get; set; }

   bool overwriteExistingGlobalAssets {get; set; }

   bool importPermissionGroupAssignments {get; set; }

   bool importPriceTables {get; set; }

   Dictionary<string,string> extraProperties { get; set; }

}

 

productToReplace — If not null, then it will refer to an existing product which will get a new staged version, and the “specified project” will be the project associated with that existing product.

projectIdToUse — If not null, then the associated project is called the “specified project” and project asset references are resolved with respect to that project; otherwise a new project will be created from the one in the file (if any).

categoryId — If not null, then the new product will be placed in that category; otherwise it will be placed in the first category in the catalog. If no categories have been created in the deployment it is an error.

importProjectAssets — If false then any project assets in the file are ignored and the new product will use files with the right name in “specified project.” If that was null then these references will fail, resulting in an error. If this argument is true then we will try to import the project assets from the file.

overwriteExistingProjectAssets — If there was already an existing project any conflicts during the import of project assets will be resolved according to this argument.

importGlobalAssets — If false then any global assets in the file are ignored and the new product will use global files with the corresponding names; if these files are missing in the deployment’s global assets then these references will fail, resulting in an error. If true then we will try to import the global assets from the file.

overwriteExistingGlobalAssets — Any conflicts during the import of global assets will be resolved according to this argument.

importPermissionGroupAssignments — The new product will allow access by the Everyone group unless this argument is true, in which case it will try to use restrict to groups with the same name as the ones assigned to the original product.

importPriceTables — The new product will have price tables with the same name as the ones assigned to the original product, unless this argument is true, in which case the entire price table from the original product will be imported as a new price table.

SINIMessage

The SINIMessage structure allows information to be conveyed back to the caller.

public class SINIMessage

{

public int Level { get; set; }

public string Message { get; set; }

public int Code { get; set; }

public string Extra { get; set; }

}

 

Level — Values in this field may be 0 (= information), 1 (= warning), or 2 (= error or exception).

Message — Message for display to a user, from the following:

Code

Message

0

Generic message (usually an exception)

100

Blank line

5001

Exception while exporting product

5002

Data error: column count different from row data

5003

Data error: more than one id={XXX} in {table}

5004

Exception while copying {filename}

5005

Trying to mark flags {XX} with mark {Y}

5100

Product could not be imported

5101

Imported new project ‘{NAME}’

5102

Exception while installing fonts

5103

Product code {CODE} was in use and will be cleared.

5104

Product Social Media Permalink {PERM} was in use and will be cleared.

5105

There are no product categories in the deployment.

5106

Imported new product ‘{NAME}’ (or: Imported new version of product ‘{NAME}’)

5107

Some project fonts could not be installed, so the product might not work properly.

5108

Unable to delete imported files in ‘{FOLDER}’

5109

The following Asset/Product Metadata field objects are not present in the deployment but have imported values: {NAMES}

5110

Imported file is from a future Storefront version ({VERSION}) and may not import correctly.

5111

Custom file {FILE} is missing from the deployment and will not be copied

5112

File {FILE} is missing from the deployment and will not be copied

5113

Replacing file: {FILE}

5114

Assigning product to categories ‘{CATEGORIES}’

5115

No file for manually generated product thumbnail: auto-generating

5116

Regenerating product thumbnail

5117

Internal error: placeholder row without an id: {row}

5118

Using price table ‘{NAME}’ which was already in the deployment.

5119

Unresolved placeholders

5120

String {S} was not re-mapped

Code — Integer uniquely identifying the message (or message template), from the table above.

Extra — Specific information from the message, such as a filename or product code.

Remarks

The product is imported as a staged product, but can be released as a live product after the import using the SINI method ReleaseProduct().

MakeOutputDirectoryForDocument

Since version 9.3

An extension can use this to change a Hosted PDF document from having a shared output folder to having an unshared one, so that more files can be added to the output. If, for example, the Hosted PDF product is a customizable manifest for a collection of media assets such as radio and TV ad rolls then this method may be used to facilitate creation of a .zip archive containing those assets and the manifest.

Method

string MakeOutputDirectoryForDocument(string docid)

Parameters

docid — The internal ID of the document

Returns

Returns the path of the new directory.

Remarks

You can identify a Hosted PDF product by doing

string productId = Storefront.GetValue(“DocumentProperty”, “ProductID”, docid);

string productType = Storefront.GetValue(“ProductProperty”, “ProductType”, productId);

Hosted PDF products have productType == “PDF”.

The extension is responsible for copying the original Hosted PDF from the shared folder to the new folder.

RevalidateDocument

Since version 3.0

Revalidates the current form filling, data list, and printing option values.

Method

bool RevalidateDocument(string documentId)

Parameters

documentId — Internal identifier of the document to revalidate.

Returns

Returns true if the document is still valid. Returning false may mean that the Revalidation succeeded but the document is invalid (if LastReturnValue is equal to eSuccess), or may mean some deeper failure (if LastReturnValue is not equal to eSuccess).

SetDocumentExtensionError

Since version 3.0

Sets an error message for a document for a given extension.

Method

bool SetDocumentExtensionError(string documentId,

                         string sxiUniqueName,

                         string message)

Parameters

documentId — Internal identifier of the document.

sxiUniqueName — Name of the module associated with this message. Typically this will be the UniqueName of the calling module.

message — The message to be set. If null, this clears the error condition with respect to the given module.

Returns

Returns true if it succeeds.

UpdateAssetProperties

Since version 3.0

Re-compute record count or regenerate the thumbnail of an asset.

Method

int UpdateAssetProperties(string assetID)

Parameters

assetID — Asset identifier.

Returns

Normally, eSuccess. Returns an eBadObjectID error if assetID does not correspond to an asset.

UpdateDocumentThumbnail

Since version 3.0

Generates a new thumbnail for a document.

Method

bool UpdateDocumentThumbnail(string documentId)

Parameters

documentId — Internal identifier of the document for which to generate the thumbnail.

Returns

Returns true if it succeeds.

Remarks

This should be called, for example, when some Form Filling values have been changed by an extension module.