Foren

DLFileEntry and FileEntry

Gwowen Fu, geändert vor 11 Jahren.

DLFileEntry and FileEntry

Expert Beiträge: 315 Beitrittsdatum: 27.12.10 Neueste Beiträge
Does anyone know what is the difference between DLFileEntry and FileEntry?

I know when to use DLFileEntry but have no idea when to use FileEntry.

Thanks!
Gwowen
thumbnail
Mika Koivisto, geändert vor 11 Jahren.

RE: DLFileEntry and FileEntry (Antwort)

Liferay Legend Beiträge: 1519 Beitrittsdatum: 07.08.06 Neueste Beiträge
DLFileEntry is part of the internal LiferayRepository implementation and you should not be using it. FileEntry is the generic repository FileEntry and the actual implementation could be one from Liferay, Sharepoint, CMIS or Documentum for instance. In Liferay 6.1 the document library was refactored to support multiple repositories the internal LiferayRepository is just one of the repository implementations. FileEntry and Folder are the generic ones and you should be using the repository API through DLAppServiceUtil otherwise you will be bypassing a lot of logic. DLFileEntry, DLFileEntryLocalService etc are considered internal implementation now and can change at anytime and should not be used directly.
thumbnail
Ivano Carrara, geändert vor 10 Jahren.

RE: DLFileEntry and FileEntry

Expert Beiträge: 345 Beitrittsdatum: 03.07.05 Neueste Beiträge
Hi Mika, what about the getFileEntryTypeId() method we used on the DLFileEntry object ? There is a corrispondent method for the FileEntry object ?? I can't find it.

And, please ... could you address me to some documentation about to get custom metadata from a FileEntry object ?

When I create a FileEntry I add my metadata using the ServiceContext object that I put in the DLAppLocalServiceUtil.addFileEntry() method ... but I can't find documentation on how to retrieve the custom metadata of the FileEntry object ...

Please could you help me ?

Thank you in advance !
Ivano C.
thumbnail
Mika Koivisto, geändert vor 10 Jahren.

RE: DLFileEntry and FileEntry

Liferay Legend Beiträge: 1519 Beitrittsdatum: 07.08.06 Neueste Beiträge
It's not exposed in FileEntry because file fileEntryTypeId is something only works with Liferay repository and not across all repositories. If you look at view_file_entry.jsp you'll see that you can get the type like this:

long fileEntryTypeId = 0;

if (fileVersion.getModel() instanceof DLFileVersion) {
	DLFileVersion dlFileVersion = (DLFileVersion)fileVersion.getModel();

	fileEntryTypeId = dlFileVersion.getFileEntryTypeId();
}
Jonathan Mattox, geändert vor 10 Jahren.

RE: DLFileEntry and FileEntry

New Member Beiträge: 13 Beitrittsdatum: 05.11.13 Neueste Beiträge
Hello, I am trying to pull values from a custom metadata set and display it as an additional column on the view/gridview along with Title, Size, Created Date. And I am having a hard time figuring out exactly what to do in my hook. I see bits and pieces of code all over the place, but I'm not sure exactly how to extend the classes to add this. I've been able to add a column to be seen on the gridview by adding an entry to the init.jsp file by adding the following around line number 151:

Before:
String defaultEntryColumns = "name,size";

After:
String defaultEntryColumns = "name,size,myNewColumn";

Then I found where you add a condition for it in view_entries.jsp, but when I output fileEntryTypeId in this if statement, I keep getting a "-1"

if (columnName.equals("myNewColumn")) {
//Logic code here
}

Also in view_entries.jsp I see the following code which gets the fileEntryTypeId, which is one of the keys I need to tap into getting the metadata since the DLFileEntry doesn't have a property for this, but I'm not sure how to tap into this to get what I need and post in in the view/gridview:

List results = null;
//List metaDataresults = null;
int total = 0;

if (fileEntryTypeId >= 0) {
Indexer indexer = IndexerRegistryUtil.getIndexer(DLFileEntryConstants.getClassName());

if (fileEntryTypeId > 0) {
DLFileEntryType dlFileEntryType = DLFileEntryTypeLocalServiceUtil.getFileEntryType(fileEntryTypeId);

dlFileEntryTypeName = dlFileEntryType.getName();
}

Also, in edit_file_entry, I see the following code which looks like it pertains, but I don't understand how to use it (starting at line 334):

<%
if (fileEntryTypeId > 0) {
try {
List<DDMStructure> ddmStructures = dlFileEntryType.getDDMStructures();

for (DDMStructure ddmStructure : ddmStructures) {
Fields fields = null;

try {
DLFileEntryMetadata fileEntryMetadata = DLFileEntryMetadataLocalServiceUtil.getFileEntryMetadata(ddmStructure.getStructureId(), fileVersionId);

fields = StorageEngineUtil.getFields(fileEntryMetadata.getDDMStorageId());
}
catch (Exception e) {
}
%>

<%= DDMXSDUtil.getHTML(pageContext, ddmStructure.getXsd(), fields, String.valueOf(ddmStructure.getPrimaryKey()), locale) %>

I also see that the table "DDMContent" gets populated with two rows when you add a document that has metadata fields. One row is for the automatically extracted data, and the other has the custom data from my custom metadata set.

I am trying to implement the following class solutions:

public class MyDLAppLocalService implements DLAppLocalService {}

and

public class MyDLFileEntryMetadataLocalService implements
DLFileEntryMetadataLocalService {}

and

public class MyDLAppLocalServiceImpl extends DLAppLocalServiceWrapper {

public MyDLAppLocalServiceImpl(DLAppLocalService dlAppLocalService) {
super(dlAppLocalService);
// TODO Auto-generated constructor stub
}
}

and

public MyDLAppLocalServiceWrapper(FileEntry fileEntry){
super((DLAppService) fileEntry);
}
}
Here is my liferay-hook.xml:

<?xml version="1.0"?>
<!DOCTYPE hook PUBLIC "-//Liferay//DTD Hook 6.1.0//EN" "http://www.liferay.com/dtd/liferay-hook_6_1_0.dtd">

<hook>
<custom-jsp-dir>/META-INF/custom_jsps</custom-jsp-dir>
<service>
<service-type>com.liferay.portlet.documentlibrary.service.DLAppLocalService</service-type>
<service-impl>com.liferay.sample.hook.MyDLAppLocalServiceImpl</service-impl>
</service>
</hook>


I find all this stuff very confusing. I don't know what to do to which class and where. I see a lot of tutorials about modifying the User's classes, but not much about this and what posts I do find, they only give a tiny snippet of code. I have no idea where that snippet came from (which file and where in that file). I'm trying to figure out all this java and liferay stuff. I've been to the liferay training classes and I'm working through the books, along with Liferay In Action. I just don't see a very clear explanation from start to finish of how to do something like this can anyone please help me?

Thanks in advance emoticon