// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
// Special characters, e.g., é, ö, à, etc. are supported in comments.

package boxconnector.actions;

import com.mendix.systemwideinterfaces.core.IContext;
import com.mendix.webui.CustomJavaAction;
import com.mendix.systemwideinterfaces.core.IMendixObject;
import static boxconnector.proxies.microflows.Microflows.updateFileInfoImpl;

/**
 * Used to update individual or multiple fields in the file object, including renaming the file, changing its description, and creating a shared link for the file. To move a file, change the ID of its parent folder.
 * 
 * Required
 * BoxFile : The file to update 
 * 
 * Optional (but at least one of them must be specified)
 * UpdateName : The new name
 * UpdateDescription: The new description
 * UpdateParentFolder: The folder where to move the file
 * UpdateSharedLink: The SharedLink to update with its new attributes
 * UpdateTags: All tags attached to this file. 
 */
public class UpdateFileInfo extends CustomJavaAction<IMendixObject>
{
	private IMendixObject __accessToken;
	private boxconnector.proxies.AccessToken accessToken;
	private IMendixObject __boxFile;
	private boxconnector.proxies.BoxFile boxFile;
	private java.lang.String updateName;
	private java.lang.String updateDescription;
	private IMendixObject __updateParentFolder;
	private boxconnector.proxies.BoxFolder updateParentFolder;
	private IMendixObject __updateSharedLink;
	private boxconnector.proxies.SharedLink updateSharedLink;
	private java.util.List<IMendixObject> __updateTags;
	private java.util.List<boxconnector.proxies.TagValue> updateTags;
	private IMendixObject __asUser;
	private boxconnector.proxies.BoxUser asUser;

	public UpdateFileInfo(IContext context, IMendixObject accessToken, IMendixObject boxFile, java.lang.String updateName, java.lang.String updateDescription, IMendixObject updateParentFolder, IMendixObject updateSharedLink, java.util.List<IMendixObject> updateTags, IMendixObject asUser)
	{
		super(context);
		this.__accessToken = accessToken;
		this.__boxFile = boxFile;
		this.updateName = updateName;
		this.updateDescription = updateDescription;
		this.__updateParentFolder = updateParentFolder;
		this.__updateSharedLink = updateSharedLink;
		this.__updateTags = updateTags;
		this.__asUser = asUser;
	}

	@Override
	public IMendixObject executeAction() throws Exception
	{
		this.accessToken = __accessToken == null ? null : boxconnector.proxies.AccessToken.initialize(getContext(), __accessToken);

		this.boxFile = __boxFile == null ? null : boxconnector.proxies.BoxFile.initialize(getContext(), __boxFile);

		this.updateParentFolder = __updateParentFolder == null ? null : boxconnector.proxies.BoxFolder.initialize(getContext(), __updateParentFolder);

		this.updateSharedLink = __updateSharedLink == null ? null : boxconnector.proxies.SharedLink.initialize(getContext(), __updateSharedLink);

		this.updateTags = new java.util.ArrayList<boxconnector.proxies.TagValue>();
		if (__updateTags != null)
			for (IMendixObject __updateTagsElement : __updateTags)
				this.updateTags.add(boxconnector.proxies.TagValue.initialize(getContext(), __updateTagsElement));

		this.asUser = __asUser == null ? null : boxconnector.proxies.BoxUser.initialize(getContext(), __asUser);

		// BEGIN USER CODE
		boxconnector.proxies.BoxFile boxFile = updateFileInfoImpl(getContext(), this.boxFile, this.updateParentFolder, this.updateSharedLink, this.updateName, this.updateDescription, this.updateTags, this.accessToken, this.asUser);
		if (boxFile != null)
			return boxFile.getMendixObject();
		else
			return null;
		// END USER CODE
	}

	/**
	 * Returns a string representation of this action
	 */
	@Override
	public java.lang.String toString()
	{
		return "UpdateFileInfo";
	}

	// BEGIN EXTRA CODE
	// END EXTRA CODE
}
