Monday, 22 August 2016

Get to know about how to switch back to flash uploader in Alfresco 5.0.x community versions

While uploading the content in the latest versions of Alfresco, you must have observed that, it always displays the file uploader different than it generally used to show in the earlier versions of Alfresco. Yes, That is correct. In the latest versions of Alfresco, it displays the dnd (drag-and-drop) uploader instead of the flash uploader in the earlier version.  Let me help you with the visuals so that it would be easy for you to understand what I am talking about, if you are new to Alfresco.
Following is the dnd uploader which you will find as the default uploader in latest Alfresco versions.
dnd uploader

Now, following is the flash uploader which used to be default uploader in the earlier versions of Alfresco.

Now, what if you want to switch back to flash uploader as default? Here, I would be sharing my understanding, if you want explicitly switch back to flash upload then how you can do that in the latest 5.0.x Alfresco versions.

Kindly take a note that, flash uploader seemed to be deliberately changed from being the default uploader in Alfresco share as a part of Tomcat 7 security fixes. Hence, if you still want to make flash uploader as the default uploader for the newer versions of Alfresco as a part of your Alfresco implementation then you should take the above point into consideration before finalizing your decision.

Now, let's take a look how we can switch back to flash uploader in 5.0.x Alfresco Community versions.

1. In file-upload.js at the location tomcat\webapps\share\components\upload inside your Alfresco installed directory, the order is explicitly specified as dnd uploader, flash uploader and simple html uploader inside show: function FU_show(config)function using if-else conditions. Modify it to change the order as following.
              var uploadType;
      if (this.hasRequiredFlashPlayer)
         uploadType = this.options.flashUploader;
      } else if (this.browserSupportsHTML5)
         uploadType = this.options.dndUploader;
      } else
         uploadType = this.options.htmlUploader;
Also, make sure that the corresponding minified js is also updated with this change.
2. Also, modify context.xml file, located at tomcat\conf inside your alfresco installed directory.
            <Context useHttpOnly="false"
3. Restart alfresco server and test the file upload now. It should now show the flash uploader back if your browser has flash plugin installed. If it still shows the dnd upload, you may try clearing out browser cache and test again.
I hope this quick information will help you out if you are stretching your head to find out where has flash upload gone and how to get it back. Hope it helps.

Saturday, 13 August 2016

Knowledge byte to validate content model without restarting Alfresco server

In any of your alfresco project, the first and very basic task that you do as a part of your technical implementation is, to start writing your content model as per your business requirement. Now, while doing so, there would be a point where you want to test if the content model xml that you have written is valid and are you able to successfully deploy it or not.

Generally, the common approach that you will take up is, deploy the content model xml and restart the alfresco server. While starting up the alfresco server, if there are any syntactical/schema errors, you will get to see those errors. Now, again you will make changes and again deploy it and restart the server until all the errors are gone and content model is successfully deployed and server is started. If you are a new developer to Alfresco, I am sure this is going to be the part of your story as I have seen many new developers facing this issue and spending their time there.

If you are seasoned alfresco professional, you must be already aware that there is a way to up-front test your content model without need of restarting server.

Let's take a look at how to validate your content model without the need to restart the alfresco server.

For example, you have created a content model named myContentModel.xml at the location
\tomcat\shared\classes\alfresco\extension inside your alfresco installed directory (We will take C:\Alfresco as an installed directory for example).

I am using windows OS and Alfresco Community edition 5.0.d.

Now, in order to test your content model, all you need to do is, Open command prompt, and execute the following command.

C:>java -cp "C:\Alfresco\tomcat\shared\classes;C:\Alfresco\tomcat\webapps\alfresco\WEB-INF\lib\*;C:\Alfresco\tomcat\webapps\alfresco\WEB-INF\classes" org.alfresco.repo.dictionary.TestModel alfresco\extension\myContentModel.xml

Once you execute the command, it will give the following result if the content model is valid, otherwise it will display the errors if its not valid.
Testing dictionary model definitions...

Models are valid.

This way you should be able to test your content model without the need of starting up the server and you will save a lot of time trial-and-error  making some minor changes to content model and restarting the server.

If you have not yet created your content model and you want to still test how the above command works then you can use an example content model shipped out-of-the-box by alfresco. It would be at
\tomcat\shared\classes\alfresco\extension\exampleContentModel.xml. It would be named as exampleContenteModel.xml.sample, you will have to just remove .sample and make it exampleModel.xml. In the above command, change the model file name at the end instead of myContentModel.xml to exampleContentModel.xml

While executing the command, If you face an error about log4j file then make sure you have given the appropriate permission. Another option is to run the command prompt as an administrator or another thing that you can try is give the absolute path to alfresco.log file in I am not going into the details here and just provided the few pointers you can try if you face log4j file related error. I am sure you must be able to figure it out based on it. If not, do drop a comment and I will help you solve that.

If you are using Linux then while specifying classpath use : instead of ; (I am sure as a first timer, you may spend a bit of time there as well in order to make a windows command work for linux)

Note : You may not find org.alfresco.repo.dictionary.TestModel class in some 4.x versions of Alfresco as it was accidentally removed from the relevant jar and later on was added back in the later versions.

Hope this blog will help you.