Alfresco Fileupload during workflow - alfresco

How can I have file upload property during workflow in my model file?
I have use alfresco 4.2 version. I like to add property for fileupload in below code which allow user to upload file during workflow.
<type name="iabookwf:createProjectSizingTask">
<parent>bpm:workflowTask</parent>
<properties>
<property name="iabookwf:mandays">
<title>Estimated Man Days</title>
<type>d:int</type>
<mandatory>true</mandatory>
</property>
<property name="iabookwf:totalCost">
<title>Total Estimated Cost</title>
<type>d:double</type>
<mandatory>true</mandatory>
</property>
</properties>
<overrides>
<property name="bpm:packageItemActionGroup">
<default>edit_package_item_actions</default>
</property>
</overrides>
<mandatory-aspects>
<aspect>bpm:assignee</aspect>
</mandatory-aspects>
</type>

You will need to add a site-webscript form control that utilizes the alfresco/components/upload/ components. The way to achieve this is to add a Share module extension, which will load the upload components onto the Tasks page or template. Then override the alfresco form control, via the web-extensions directory to include the Upload button on the Form control for associations.
In addition to the Upload button, you will need to add an upload handler so that Alfresco knows how to handle the newly uploaded file. Generally this can go into a workflow site, a workflow directory, dedicated for workflow items, etc. You can copy/paste and extend the alfresco's upload.post.* webscripts and modify them for your own use. However, regardless of where the newly uploaded files go, the user accessing the workflow, must have permissions to access the file, otherwise the associated entry will be blank for that user.
Here is a screenshot of a typical project layout:
Once your form controls are in place, edit the share-config-custom.xml to define the form used in your workflow, and override the form entry for that control, to use your new control.
share-config-custom.xml
<alfresco-config>
<config evaluator="string-compare" condition="activiti$activitiAdhoc">
<forms>
<form>
<appearance>
<field id="packageItems">
<control >
<control-param name="allowUpload">true</control-param>
</control>
</field>
</appearance>
</form>
</forms>
</config>
For a working example, you can see may visit my blog on this feature which includes source codes for an Alfresco Enterprise Maven Project.

Related

Is there a way to tell if a particular *-context.xml file has been loaded?

I was advised that the proper way to load multiple share customisations was to create a custom bootstrap for it like so:
<!-- Provide extensions config -->
<bean id="MyCustomClientConfig" class="org.springframework.extensions.config.ConfigBootstrap" init-method="register">
<property name="configService" ref="web.config" />
<property name="configs">
<list>
<value>classpath:alfresco/web-extension/mycustom-config.xml</value>
</list>
</property>
</bean>
However the customisations in my custom share config, specifically making an aspect visible, does not seem to be working.
I'd like to find a log4j debugging key that I can enable or 'turn up' to get more debugging info out, ideally to see if this bootstrap, which is in a *-context.xml file is being loaded.
I'm deploying this code as an AMP if that's relevant, and I've placed the context file in config/alfresco/web-extension

Alfresco Java backend webscript: reading properties file

I need to include a properties file into my Alfresco webscript developed in Java.
How can I include it?
The properties file includes a hash map useful for service work.
How can use ResourceBundle?
Note that it is not a i18n file.
Thanks
-- Marco
you should be able to get your props as map via spring injection with your java webscript bean:
<property name="your map">
<bean class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="location" value="your_properties.properties"/>
</bean>
</property>

Tridion deployer removes localized/parent files

We are facing weird behaviour during publishing pages in Tridion.
We have English pages in 050 publication and same pages are localized in 060 publication. Let's take a sample page accounts (tcm:120-1234) in English publication and same localized page (tcm:125-1234) in Spanish Publication.
When we publish English page, accounts, it gets published successfully but local deployer removes the its spanish page (tcm:125-1234). When we publish Spanish page, it removes its English page (tcm:120-1234).
We have verified the deployer side and confirmed that other file gets removed from the server itself.
Please refer below the deployer log for instructing to remove the page. But we are not sure why it removes other publication file. Is it becasue of the same page item id? I think it shouldn't, since it is localized.
DEBUG FSEntityManager - Removing pagemeta/pageurl/business/accounts.content in transaction tcm:0-754-66560.
We understand from this log that this been instructed from deployer but not sure how & why it was requested. We are analyzing what FSEntityManager class is doing.
Can anyone help me on this?
That looks like both publications share the same webroot. Check your storage Conf and publication path properties.
If the File System is used for storing content and metadata, the content of the Master or Child Publications will be over written.
To account for this, set explicit settings for metadata in cd_storage_conf.xml, to ensure that all metadata does not go to the same storage location, for example:
<Storage Type="filesystem" Class="com.tridion.storage.filesystem.FSDAOFactory" Id="defaultFile" defaultFilesystem="false">
<Root Path="c:\published\localFileSystem" />
</Storage>
<Storage Type="filesystem" Class="com.tridion.storage.filesystem.FSDAOFactory" Id="defaultDataFile" defaultFilesystem="true" defaultStorage="true">
<Root Path="c:\published\localFileSystem\data" />
</Storage>
<ItemTypes defaultStorageId="defaultFile" cached="false">
<!-- Query type mapping is replacement for Query gnenerator. If there was query generator defined in a Broker configuration then Query type mapping should be binded to default DB. -->
<Item typeMapping="Query" storageId="defaultdb"/>
<Item typeMapping="PageMeta" cached="true" storageId="defaultDataFile"/>
<Item typeMapping="ComponentPresentationMeta" cached="true" storageId="defaultDataFile"/>
<Item typeMapping="ComponentMeta" cached="true" storageId="defaultDataFile"/>
</ItemTypes>

Audience manager - Com.Tridion.Broker.StorageException: Transaction rolled back

Edit - Should add this is for Tridion 2011 SP1
When attempting to save a new audience manager profile using the TOM.NET API, I receive the following error:
Com.Tridion.Broker.StorageException: Transaction rolled back, error executing work, error executing work
at Codemesh.JuggerNET.NTypeValue.Throw(Int64 inst)
at Codemesh.JuggerNET.JavaClass.ThrowTypedException(Int64 inst)
at Codemesh.JuggerNET.JavaMethod.CallVoid(JavaProxy jpo, Object val)
at Tridion.OutboundEmail.ContentDelivery.Profile.Contact.Save(String pageUri)
Usually with Storage Exceptions I keep thinking there is something wrong with my cd_licenses.xml file on my presentation server, or configuration doesn't seem to be pointing at it....but I've checked over both and everything appears to be ok.
Anyone come across this message before when saving audience manager profiles?
Possible causes for this problem that I've seen:
You're missing some JAR files that are needed
You're using the 32-bit version of the DLLs on a 64-bit system (or vice versa)
Having Outbound Email and Content Delivery in the same application pool
Check your cd_stroage_conf.xml to make sure you have correct storage bindings included.
<StorageBindings>
<Bundle src="AudienceManagerDAOBundle.xml"/>
</StorageBindings>
<Storage Id="profiledb" Class="com.tridion.storage.persistence.JPADAOFactory" Type="persistence"
dialect="MSSQL">
<Pool CheckoutTimeout="120" IdleTimeout="120" MonitorInterval="60" Size="5" Type="jdbc"/>
<DataSource Class="com.microsoft.sqlserver.jdbc.SQLServerDataSource">
<Property Name="serverName" Value="localhost"/>
<Property Name="portNumber" Value="1433"/>
<Property Name="databaseName" Value="tridion_submgmt_DB"/>
<Property Name="user" Value="username"/>
<Property Name="password" Value="password"/>
</DataSource>
</Storage>
Also, you need to have item typemapping to the same DB.
<Item typeMapping="AudienceManagerProfile" storageId="profiledb"/>
Optionally, if you are using tracking you should have the tracking db and tracking typemapping as well.

Spring MVC : using wildcards in <mvc:resources>

I'm implementing a cache busting system for a Spring MVC application.
For this system to work, I have to strip the "cache busting code" from a given url. Let's say my generated cache busting code is "123" and I have a .css url that is: /public-123/css/style.css. In this example, I want /public/css/style.css to be succesfully called (-123 must be stripped).
This works in my "mvc-config.xml" context file:
<mvc:resources mapping="/public-123/**" location="/public/" />
But I would also like any cache busting code to work, even if it's not the current one. For example, I would also like /public-456/css/style.css to reach the style.css file.
If I try to add another wildcard to the mapping:
<mvc:resources mapping="/public-*/**" location="/public/" />
It doesn't work! I receive a 404....
How could I specify the "mapping" attribute so any code after the "public-" part is well managed?
One way to handle this is to use Spring EL, as shown in the Spring docs:
<mvc:resources mapping="/resources-#{applicationProps['application.version']}/**" location="/public-resources/"/>
You could probably store the "123" part in a properties file so it only gets set once. E.g. via property-placeholder:
<context:property-placeholder location="classpath:myApp.properties"/>
<mvc:resources mapping="/resources-${cache.code}/**" location="/public-resources/"/>
This has the advantage of being able to read this code in your JSP pages (to generate links) via the same properties value.
I managed to get this working by manually defining the ResourceHttpRequestHandler to handle assets that are located on the filesystem alongside the <mvc:resources /> tag:
<bean id="assetsResourceHandler" class="org.springframework.web.servlet.resource.ResourceHttpRequestHandler">
<property name="locations">
<list>
<bean class="org.springframework.core.io.UrlResource">
<constructor-arg value="file:#{applicationProps['assets.basedir']}"></constructor-arg>
</bean>
</list>
</property>
</bean>
I guess you're doing this to achieve cache busting for your static resources.
In the meantime, Spring 4.1 has dedicated features for this, so you can remove a lot of that custom configuration.
Something like this:
<mvc:resources mapping="/public/**" location="/public/"/>
<mvc:resource-chain resource-cache="true">
<mvc:resolvers>
<mvc:version-resolver>
<mvc:content-version-strategy patterns="/**"/>
</mvc:version-resolver>
</mvc:resolvers>
</mvc:resource-chain>
</mvc:resources>

Resources